package api

import (
	"essay/api/handler"
	"essay/consts"
	"github.com/gin-gonic/gin"
	jwt2 "github.com/golangblogs/gojwt"
)

func LoadRoutes(r *gin.Engine) {
	api := r.Group("/api")
	{
		user := api.Group("/user") //todo: 用户模块
		{
			user.POST("/createUser", handler.CreateUser) //用户注册
			user.POST("/loginUser", handler.LoginUser)   //用户登录
		}
		essay := api.Group("/essay") // todo: 文章模块
		{
			essay.Use(jwt2.JWTAuth(consts.JWT_SELECT_KEY))
			essay.POST("/createEssay", handler.CreateEssay) //发布文章
			essay.POST("/queryEssay", handler.QueryEssay)   //浏览文章
		}
		like := api.Group("/like") // todo: 点赞模块
		{
			like.Use(jwt2.JWTAuth(consts.JWT_SELECT_KEY))
			like.POST("/createLike", handler.CreateLike)                           //点赞
			like.POST("/createLikeComment", handler.CreateLikeComment)             //评论点赞
			like.POST("/createLikeAnswerComment", handler.CreateLikeAnswerComment) //回复评论点赞
			like.POST("/deleteLikeComment", handler.DeleteLikeComment)             //删除点赞
			like.POST("/deleteLikeAnswerComment", handler.DeleteLikeAnswerComment) //删除回复点赞
		}
		comment := api.Group("/comment") //todo: 评论模块
		{
			comment.Use(jwt2.JWTAuth(consts.JWT_SELECT_KEY))
			comment.POST("/createComment", handler.CreateComment) //发布评论
			comment.POST("/answerComment", handler.AnswerComment) //回复评论
		}

	}
}
